import libnum

c = 38127524839835864306737280818907796566475979451567460500065967565655632622992572530918601432256137666695102199970580936307755091109351218835095309766358063857260088937006810056236871014903809290530667071255731805071115169201705265663551734892827553733293929057918850738362888383312352624299108382366714432727
e = 65537

f = open("output.txt", "r")
a = f.readlines()

p = libnum.gcd(int(a[0]), int(a[1]))
print(p)

a = a[::-1]

for i in a:
    n = int(i)
    q = n // p
    phi = (p - 1) * (q - 1)
    d = libnum.invmod(e, phi)
    m = pow(c, d, n)
    c = m
print(libnum.n2s(c))
